package scoutobahn.xml.automaton;

import org.xml.sax.Attributes;
/**
 * State of a parser.
 * @author mark
 *
 */
public abstract class ParserState {
    private final StateManager manager;
    /**
     * Constructs a new parser with a given StateManager.
     * @param stateManager The StateManager that is responsible
     */
    public ParserState(final StateManager stateManager) {
        this.manager = stateManager;
    }
    /**
     * When a new element is started, that state should process the element
     * and return the following state.
     * @param nameSpace The namespace of the xml element
     * @param localName The xml local name of the found element
     * @param qName The fully qualified element name
     * @param attr The attributes of the element
     * @return The following state
     */
    public abstract ParserState startElement(String nameSpace,
            String localName, String qName, Attributes attr);
    /**
     * Called when an element ends, the parser should process it
     * and return the following state.
     * @param namespace The namespace of the element
     * @param localName The local name of the xml element
     * @param qName The fully qualified name
     * @return The following state
     */
    public abstract ParserState endElement(String namespace,
            String localName, String qName);
    /**
     * Returns the StateManager responsible for this state.
     * @return The StateManger in charge
     */
    public StateManager getStateManager() {
        return manager;
    }
}
